张于豪 11:52:54
<template>
  <!-- 头部 -->
  <header class="header">
    <van-icon name="arrow-left" size="18px" @click="toCategory" />
    <div class="ct1_name">音乐</div>
    <van-search shape="round" class="input_search" placeholder="搜索" />
    <div class="open_button">打开APP</div>
  </header>
  <div class="listenLsit_container">
    <!-- 导航 -->
    <div class="tab_nav" v-show="isShowNav">
      <div class="tab_lsit">

        <van-tabs color="red" title-inactive-color="#A3A3AC" v-if="isShow" v-model:active="active"
          title-active-color="red">
          <van-tab title="全部">
          </van-tab>
          <van-tab v-for="item in 8" :key="item" title="催眠音乐">
          </van-tab>
        </van-tabs>

        <div v-else class="text_select">请选择分类</div>
      </div>
      <div class="select_target" @click="handleChange">
        <van-icon v-if="isShow" name="arrow-down" color="#A3A3AC" />
        <van-icon v-else name="arrow-up" color="#A3A3AC" />
      </div>
    </div>
    <!-- 分类 -->
    <div class="category" v-show="!isShow">
      <div class="category_lsit">
        <div class="category_item" @click="handleChangeCategory(navItem.name, index)"
          v-for="(navItem, index) in lsitenNavList" :key="navItem.cid">{{ navItem.title }}</div>
      </div>
    </div>
    <!-- 内容列表 -->
    <div class="content_list" ref="aaa">
      <div class="content_item" v-for="item in 10" :key="item">
        <img :src="piano">
        <div class="text_content">
          <div class="title">《夜色钢琴曲》</div>
          <div class="content">全站最高播放量钢琴曲的音乐月光下，洗涤凡尘</div>
          <div class="play_num_renew">
            <div class="play_num">354</div>
            <div class="renew">13.19亿</div>
          </div>
        </div>
      </div>

    </div>


  </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { NavList } from '@/type/resType/listenListResType'
import router from '@/router/index'
import piano from '@/static/images/piano.jpg'
import categoryRequest from "@/api/category";
import reminder from '@/utils/reminder';

const props = defineProps({
  id: {
    type: String,
    required: true
  }
})
console.log(">>>>>>>>", props.id);
const isShow = ref(true)
const active = ref(0);
const isShowNav = ref(true)

// 导航列表数据
const lsitenNavList = ref<NavList>([])

const aaa = ref<HTMLElement>()


// 跳转到分类的回调函数
function toCategory() {
  router.back()
}
// 获取所有的分类信息列表数据
const forGetAllCategoryList = async () => {
  try {
    let { data: { categories } } = await categoryRequest.getCategoryInfo();
    console.log(">>>>>>>>>>>>>>>>", categories);
    let item = categories.find(item => item.id === +props.id);
    console.log(">>>>>>>>>>", item);
  } catch (error) {
    reminder("网络连接异常");
  }
}
onMounted(() => {
  forGetAllCategoryList();
})



// 操作是否显示的回调函数
function handleChange() {
  isShow.value = !isShow.value
}

</script>

<style  scoped lang="less">
// 头部
.header {
  position: sticky;
  top: 0px;
  display: flex;
  justify-content: space-between;
  height: 30px;
  align-items: center;
  padding: 15px 15px 5px 15px;
  background: #fff;

  .ct1_name {
    font-size: 16px;
    min-width: 36px;
    height: 30px;
    line-height: 30px;
  }


  .logo_icon {
    width: 75px;
    height: 15px;
    background: pink;
  }

  .input_search {
    // --van-search-content-background : yellow;
    --van-search-padding: 0px 10px 0px 0;
    --van-search-input-height: 30px;
  }



  .open_button {
    width: 67px;
    height: 28px;
    font-size: 12px;
    line-height: 30px;
    color: #f86442;
    text-align: center;
    border: 1px solid #f66847;
    border-radius: 20px;
  }

}

.listenLsit_container {
  position: relative;



  // 导航
  .tab_nav {
    height: 45px;
    font-size: 14px;
    border-bottom: 1px solid #e5e3e3;
    display: flex;

    .tab_lsit {
      width: 88.6%;
      color: #A3A3AC;

      :deep(.van-tab--active) {
        font-size: 18px;
      }
    }

    .text_select {
      width: 88.6%;
      line-height: 45px;
      margin-left: 15px;

    }

    .select_target {
      width: 43px;
      height: 43px;
      border-left: 1px solid #e5e3e3;
      text-align: center;
      line-height: 43px;
    }
  }

  // 内容列表
  .content_list {
    padding: 15px;

    .content_item {
      display: flex;
      align-items: center;
      height: 120px;
      border-bottom: 1px solid #e5e3e3;
      margin-left: 15px;

      img {
        width: 70px;
        height: 70px;
      }

      .text_content {
        height: 70px;
        width: 266px;
        margin-left: 10px;

        .title {
          font-size: 16px;
          height: 22px;
        }

        .content {
          margin-top: 4px;
          font-size: 13px;
          color: #999999;
        }

        .play_num_renew {
          margin-top: 10px;
          display: flex;
          align-items: center;
          color: #A3A3AC;
          font-size: 14px;

          .bf_icon {
            width: 14px;
            height: 12px;
            margin-right: 4px;
          }

          .play_num {
            margin-right: 15px;
          }
        }
      }


    }
  }

  .category {
    position: absolute;
    width: 100%;
    height: 400px;
    background: #fff;
    overflow: hidden;
    overflow-y: scroll;

    .category_lsit {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;

      .category_item {
        width: 103px;
        height: 32px;
        font-size: 16px;
        margin-top: 14px;
        line-height: 32px;
        text-align: center;
        background: #f3f4f5;
      }
    }
  }

}

.active {
  --van-tab-font-size: 30px;
}
</style>
